package com.jumper.study.admin.dto.resp;

import java.time.LocalDateTime;
import java.time.ZoneOffset;

//价格单位分，显示时转成元
public class LessonResp {
    private Long id;

    private Integer categoryId;

    private LessonCategoryResp category;

    private String title;

    private String thumb;

    private String summary;

    private String content;

    private Integer price;

    private Integer marketPrice;

    private Boolean recommend;

    private Boolean onself;

    private String teachers;

    private Long sort;

    private LocalDateTime updatedAt;

    public LessonResp(Long id, Integer categoryId, String title, String thumb, String summary, String content,
            Integer price, Integer market_price, Boolean recommend, Boolean onself, String teachers, Long sort,
            LocalDateTime updatedAt) {
        this.id = id;
        this.categoryId = categoryId;
        this.category = null;
        this.title = title;
        this.thumb = thumb;
        this.summary = summary;
        this.content = content;
        this.price = price;
        this.marketPrice = market_price;
        this.recommend = recommend;
        this.onself = onself;
        this.teachers = teachers;
        this.sort = sort;
        this.updatedAt = updatedAt;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Integer getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Integer categoryId) {
        this.categoryId = categoryId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getThumb() {
        return thumb;
    }

    public void setThumb(String thumb) {
        this.thumb = thumb;
    }

    public String getSummary() {
        return summary;
    }

    public void setSummary(String summary) {
        this.summary = summary;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Integer getPrice() {
        if (price != null) {
            return price / 100;
        }
        return price;
    }

    public void setPrice(Integer price) {
        this.price = price;
    }

    public Integer getMarketPrice() {
        if (marketPrice != null) {
            return marketPrice / 100;
        }
        return marketPrice;
    }

    public void setMarketPrice(Integer marketPrice) {
        this.marketPrice = marketPrice;
    }

    public Boolean getRecommend() {
        return recommend;
    }

    public void setRecommend(Boolean recommend) {
        this.recommend = recommend;
    }

    public Boolean getOnself() {
        return onself;
    }

    public void setOnself(Boolean onself) {
        this.onself = onself;
    }

    public String getTeachers() {
        return teachers;
    }

    public void setTeachers(String teachers) {
        this.teachers = teachers;
    }

    public Long getSort() {
        return sort;
    }

    public void setSort(Long sort) {
        this.sort = sort;
    }

    public LessonCategoryResp getCategory() {
        return category;
    }

    public void setCategory(LessonCategoryResp category) {
        this.category = category;
    }

    public Long getUpdatedAt() {
        return updatedAt.toEpochSecond(ZoneOffset.UTC);
    }

    public void setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }
}
